package web

import (
	"context"

	"portal/internal/errorx"
	"portal/internal/svc"
	"portal/internal/types"
	"portal/model"

	"github.com/zeromicro/go-zero/core/logx"
)

type JobDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	jobModel model.AwJobsModel
}

func NewJobDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobDetailLogic {
	return &JobDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
		jobModel: model.NewAwJobsModel(svcCtx.Orm),
	}
}

func (l *JobDetailLogic) JobDetail(req *types.IdRequest) (resp *types.CommonResponse, err error) {
	// todo: add your logic here and delete this line

	jobDto,err := l.jobModel.FindOne(l.ctx,req.Id)
	if err != nil {
		return nil,errorx.NewBizError(500,err.Error())
	}
	jobVo := types.Job {
		Id: jobDto.Id,
		CreateTime: jobDto.CreateTime,
		UpdateTime: jobDto.UpdateTime,
		Description: jobDto.Description,
		Requirement: jobDto.Requirement,
		Title: jobDto.Title,
	}
	return &types.CommonResponse{
		Status: 200,
		Msg: "查询成功",
		Data: jobVo,
	},nil
}
